from IPython.display import Image
def render_image(name):
img_path = name + '.png'
cmd.png(img_path, 500, 600)
return Image(filename=img_path)
cmd.reinitialize()
загружаем структуру белка, задаем отрисовку и фокусируемся на 4 и 5 остатках
import __main__
__main__.pymol_argv = [ 'pymol', '-cp' ]
import pymol
#pymol.finish_launching()
from pymol import cmd,stored
from IPython.display import Image
def render_image(name):
img_path = name + '.png'
cmd.png(img_path, 500, 600)
return Image(filename=img_path)
cmd.reinitialize()
cmd.do('''
fetch 1cll, async=0
as sticks, n. C+O+N+CA
zoom i. 4+5
mset 1 x10
mview store
png 1.png, width=720, height=480, ray=1
''')
Image('1.png')
Итерируемся по остаткам и красим их, красный убывает
python
stored.r = []
cmd.iterate('1cll and n. CA','stored.r.append(resi)')
import numpy as np
length = len(stored.r)
colors = np.linspace(1,0, length)
for k,i in enumerate(stored.r):
cmd.set_color('col%d' % k, [colors[k], 0.5, 0.5]) # make custom color
cmd.set('cartoon_color','col%d' % k ,'resi %d' % int(i)) # apply color to residue
cmd.show_as('cartoon','all')
cmd.zoom()
cmd.do('png 2.png, width=1080, height=720, ray=1')
python end
Image('2.png')
Фильм с итерацией по остаткам
for i in range(length):
cmd.frame((30*i)+1)
cmd.zoom( 'n. CA and i. %d+%d' % (i,i+7))
cmd.mview('store')
Изменяем форму белка 1LMP с помощью Sculpting
Image('21.png')
Лиганд образует хорощую водородную связь со 101-м аспартатом
cmd.do('''
reini
fetch 1lmp
remove resn HOH
bg_color white
select ligand, resn nag+ndg
dist hbond1, ligand, resi 101, mode=2
set label_size, 20
show sticks, resi 101
orient resi 52 or resn NDG
zoom resi 101 or resn NDG, 1
view1 = get_view()
set cartoon_transparency, 0.5
png 22.png, width=1080, height=720, ray=1
delete hbond1
''')
Image('22.png')
Заменим этот остаток на аланин
cmd.do('''
wizard mutagenesis
refresh_wizard
python
cmd.get_wizard().do_select("resi 101")
cmd.get_wizard().set_mode("ALA")
cmd.get_wizard().apply()
cmd.set_wizard()
python end
dist hbond1, ligand, resi 101, 5, mode=2
set_view(view1)
set cartoon_transparency, 0.5
png 22b.png, width=1080, height=720, ray=1
''')
Image('22b.png')
Два белка рядом
cmd.do('''
set_view(view0)
fetch 1lmp, native
remove resn HOH
translate [30, 0, 0], native
orient all
select ligand1, native and resn nag+ndg
select ligand2, 1lmp and resn nag+ndg
as cartoon, not ligand*
color wheat, native
color palegreen, 1lmp
color grey50, ligand*
show sticks, resi 101
color green, resi 101 and 1lmp
color orange, resi 101 and native
png 23.png, width=1080, height=720, ray=1
''')
Image('23.png')
Совмещение белков
cmd.do('''
mset 1 x150
set movie_auto_interpolate, off
frame 30
align native, 1lmp
mview store, object=native
mview store, object=1lmp
frame 150
mview store, object=native
mview store, object=1lmp
frame 1
translate [15, 0, 0], object=native
translate [-15, 0, 0], object=1lmp
mview store, object=native
mview store, object=1lmp
mview reinterpolate, object=native
mview reinterpolate, object=1lmp
python
cmd.frame(1)
cmd.zoom()
cmd.mview('store')
cmd.frame(30)
cmd.zoom()
cmd.mview('store')
cmd.frame(60)
cmd.zoom('all', -5)
cmd.mview('store')
cmd.frame(90)
cmd.zoom('resi 101', 2)
cmd.mview('store')
cmd.frame(150)
cmd.turn('y', 100)
cmd.mview('store')
cmd.mview('reinterpolate')
cmd.mstop()
for x in range(0, 150, 3):
cmd.mpng('mymovie/', x + 1, x + 1, mode=1, width=720, height=480)
python end''')
from IPython.display import Image, display
display(Image(filename='movie.gif', format='png'))
Присоединение TAMRA к серину 81
cmd.do('''
reini
fetch 1lmp
hide nonbonded
bg_color white
load tamra.sdf
remove tamra and id 54
show sticks, resi 81
remove resi 81 and name OG1
fuse tamra and donor, resi 81 and name CB, mode=1
torsion 50
remove tamra
orient resi 81
turn y, -150
unpick
png 24.png, width=1080, height=720, ray=1
orient 1lmp
color orange, resi 81
png 24b.png, width=1080, height=720, ray=1
''')
Image('24.png')
Общий план
Image('24b.png')
Полиаланиновая альфа-спираль
cmd.do('''
reini
bg_color white
fragment ALA
''')
for i in range(1, 101):
cmd.do(f'''
edit resi {i} and name C
editor.attach_amino_acid('pk1', 'ALA')
''')
phi = -57
psi = -47
for i in range(1, 101):
cmd.do(f'''
set_dihedral resi {i} and name N, resi {i} and name CA, resi {i} and name C, resi {i+1} and name N, {phi}
set_dihedral resi {i} and name C, resi {i+1} and name N, resi {i+1} and name CA, resi {i+1} and name C, {psi}
''')
cmd.do('''
hide cartoon
orient resi 10+90
unpick
png 25.png, width=1080, height=720, ray=1
''')
Image('25.png')